﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using ueEngine.Biz.Inf.Entities.DBSupport;
using ueEngine.Framework.Exception;

namespace ueEngine.Biz.Inf.Entities
{
    [Table("SystemAdvert")]
    public class SystemAdvert : BaseEntity<SystemAdvert>
    {
        private SystemAdvert() { }
        public override SystemAdvert Get(System.Linq.Expressions.Expression<Func<SystemAdvert, bool>> where)
        {
            using (Context ctx = new Context())
            {
                var item = ctx.SystemAdvert.FirstOrDefault(where);
                if (item != null)
                {
                    this.Code = item.Code;
                    this.ContactId = item.ContactId;
                    this.Id = item.Id;
                    this.LinkTo = item.LinkTo;
                    this.Title = item.Title;
                    this.Url = item.Url;
                    return this;
                }
                return null;
            }
        }
        #region Fileds
        [Column("Id",TypeName="int")]
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        /// <summary>
        /// 版区代号
        /// 一个版区代号代表网站中某一个广告位子
        /// </summary>
        [Column("Code",TypeName="int")]
        public int Code { get; set; }

        /// <summary>
        /// 图片主题
        /// </summary>
        [Column("Title",TypeName="nvarchar")]
        [StringLength(200)]
        public string Title { get; set; }

        /// <summary>
        /// 图片资源链接地址
        /// </summary>
        [Column("Url",TypeName="nvarchar")]
        [StringLength(200)]
        public string Url { get; set; }

        /// <summary>
        /// 图片链接到的地址
        /// </summary>
        [Column("LinkTo",TypeName="nvarchar")]
        [StringLength(200)]
        public string LinkTo { get; set; }

        /// <summary>
        /// 广告位合同Id
        /// </summary>
        [Column("ContactId",TypeName="int")]
        public int ContactId { get; set; }
        #endregion
    }
}
